//
//  KWallDynamicsCell.m
//  Keping
//
//  Created by apple on 2017/12/7.
//  Copyright © 2017年 柯平. All rights reserved.
//

#import "KWallDynamicsCell.h"
#import <TZImagePickerController/TZImageManager.h>

@interface KWallDynamicsCell()

@property (nonatomic, weak) IBOutlet UIImageView *dynamicsImg;
@property (nonatomic, weak) IBOutlet UIButton *deleteBtn;

@end

@implementation KWallDynamicsCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setModel:(TZAssetModel *)model {
    
    if (!model)
        return;
    _model = model;
    [[TZImageManager alloc] getOriginalPhotoWithAsset:model completion:^(UIImage *photo, NSDictionary *info) {
        BOOL isInfo = info[PHImageResultIsDegradedKey];
        if (isInfo) {
            self.dynamicsImg.image = photo;
        }
    }];
    self.deleteBtn.hidden = NO;
}

- (void)setAddImg:(NSString *)addImg {
    if (!addImg)
        return;
    self.dynamicsImg.image = [UIImage imageNamed:addImg];
    self.deleteBtn.hidden = YES;
}

- (IBAction)deleteImg:(id)sender {
    if (self.deleteWallDynamiscsImg) {
        self.deleteWallDynamiscsImg(self.model);
    }
}


@end
